<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function isZhiShu(x) {
            var flag = true;
            for (var i = 2; i <= x / 2; i++) {
                if (x % i == 0) {
                    flag = false;
                    break;
                }
            }
            if (flag == true) {
                alert(x + "是素数");
            } else {
                alert(x + "不是素数");
            }
        }
        var x = prompt("输入数字");
        isZhiShu(x);
    </script>
</body>

</html>